import mkdirp from 'mkdirp';

const settings = require('../../package.json');
const APP_NAME = settings.name;
const LOG_DIR = `/data/logs/${APP_NAME}`;

mkdirp(LOG_DIR);

export default {
    hbm: {
        expire: 330,
        interval: 300,
    },
    mysql: {
        host: 'db-master.xxxxxx.domain',
        port: '13476',
        user: 'root',
        password: 'root',
        database: 'test',
    },
    redis: {
        host: '10.0.0.0',
        port: 6379,
    },
    redisBackend: {
        host: '10.0.0.0',
        port: 6379,
    },
    rabbit: {
        uri: 'amqp://khw-sms:AfAseArybVebBJ6NU8qtWDsggH4weseY@127.0.0.1:5672/%2Fsms',
        schema: [
            {
                exchange: 'exchange0',
                type: 'direct',
                options: {},
                bindings: [
                    {
                        routingPattern: 'test',
                        destination: {
                            queue: 'user.testqueue',
                            messageSchema: {
                                type: 'object',
                                properties: {
                                    foo: { type: 'string' },
                                },
                                required: ['foo'],
                                // http://json-schema.org
                            },
                            options: {/* queue options */},
                        },
                        args: {},
                    },
                ],
            },
        ],
    },
    mongo: {
        uri: 'mongo.xxxxxxx.domain/khw',
        options: {
            server: {
                poolSize: 10,
                reconnectTries: Number.MAX_VALUE,
                socketOptions: {
                    keepAlive: 120,
                },
            },
            replset: {
                socketOptions: {
                    keepAlive: 120,
                },
            },
        },
    },
    useAccessLog: true,
    corsCheckDomain: /.*/,
    log4js: {
        appenders: [
            {
                type: 'logLevelFilter',
                level: 'INFO',
                appender: {
                    type: 'dateFile',
                    absolute: true,
                    filename: `${LOG_DIR}/access.log`,
                    pattern: '.yyyy-MM-dd',
                    alwaysIncludePattern: false,
                    backups: 60,
                },
            },
            {
                type: 'logLevelFilter',
                level: 'WARN',
                appender: {
                    type: 'dateFile',
                    absolute: true,
                    filename: `${LOG_DIR}/error.log`,
                    pattern: '.yyyy-MM-dd',
                    alwaysIncludePattern: false,
                    backups: 60,
                },
            },
        ],
    },
};
